﻿$(document).ready(function () {
    $("#company").submit(function () {
        App.blockUI($('body'));
        $.ajax({
            url: "/Utilities/SaveCompany",
            data: $(this).serialize(),
            success: function () {
                $("#companyp").submit();
                alert("Success!");
                App.unblockUI($('body'));
            }
        });
        return false;
    });

    $("#companyp").submit(function () {
        App.blockUI($('.tb-c'));
        $.ajax({
            url: "/Utilities/variables",
            data: $(this).serialize(),
            success: function (data) {
                $('#fixhead').html(data);
                InitDatatable();
                InitTableSelected();
                App.unblockUI($('.tb-c'));
            }
        });
        return false;
    });
});
function CompanyVariablesDetail(CompanyVariableID) {
    App.blockUI($('.companyDetail'));
    $.ajax({
        url: "/Utilities/VariableDetail?CompanyVariableID=" + CompanyVariableID,
        success: function (data) {
            $('#company').html(data);
            App.unblockUI($('.companyDetail'));
        }
    });
}

function DeleteCompany(CompanyVariableID) {
    if (confirm('Are you sure?')) {
        $.ajax({
            url: "/Utilities/DeleteCompany",
            data: { CompanyVariableID: CompanyVariableID },
            success: function (data) {
                $("#companyp").submit();
                CompanyVariablesDetail();
                alert("Success!");
            }
        });
    }
}

